﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using LyData.Data;

public partial class Admin_HtmlCreate : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string str = "";
        if (Request.Params["hid"] != null)
        {
            str = Request.Params["hid"].ToString();
            if (str == "1")  //生成新闻单页
            {
                string strwhere = string.Format("MenuId={0}", 1);
                IDb db = new DbFactory().DriverDb();
                db.Open();
                DataTable table = db.DataTable("OrderId,ClassName,FileName,ParentId,ArticleClassId", "ArticleClass", strwhere, "OrderId ASC");
                db.Close();

                if(table!=null)
                {
                    for (int i = 0; i < table.Rows.Count;i++ )
                    {
                        CreateHtml.CreateNewsHtml(table.Rows[i], "../Template/NewsInfo.html");
                    }
                }
            }
            else if (str == "2") //生成产品单页
            {
                string strwhere = string.Format("MenuId={0}", 1);
                IDb db = new DbFactory().DriverDb();
                db.Open();
                DataTable table = db.DataTable("OrderId,ClassName,FileName,ParentId,PicClassId", "PicClass", strwhere, "OrderId ASC");
                db.Close();

                if (table != null)
                {
                    for (int i = 0; i < table.Rows.Count; i++)
                    {
                        CreateHtml.CreateProductHtml(table.Rows[i], "../Template/ProductInfo.html");
                    }
                }
            }
            else if (str == "3")
            {
                CreateHtml.CreateIndex("../Template/Index.html");//生成首页
                CreateHtml.CreateContact("../Template/Contact.html");//生成联系我们
            }
            else
            {
                WebPublic.WebPublic.ShowAndRedirect(this, "生成失败！", "MenuAdd.aspx");
            }
            WebPublic.WebPublic.ShowAndRedirect(this, "生成成功！", "MenuAdd.aspx");
        }
        else
        {
            WebPublic.WebPublic.ShowAndRedirect(this, "生成失败！", "MenuAdd.aspx");
        }

    }
}
